<html>
  <body>

  </body>

  <script>

function objectFactory(){

const constructor = Array.prototype.shift.call(arguments)

if(typeof constructor !=='function'){
  return
}

let newObject = {};
let result = null;

newObject = Object.create(constructor.prototype)
//newObject.__proto__ = constructor.constructor

result = constructor.apply(newObject,arguments)

var isObject = typeof result === 'object' && result !== null;
var isFunction = typeof result === 'function';
    if(isObject || isFunction){
        return result;
    }
    
    return newObject;

}

function myConstructor(){
this.data = 'my constructor'
}

myConstructor.prototype.getData = function(){

return this.data
}

const instance1 = objectFactory(myConstructor)

console.log(instance1.__proto__)



  </script>
</html>